package org.demo.swagger2.dao;

import org.apache.ibatis.annotations.*;
import org.demo.swagger2.domain.User;

import java.util.List;

@Mapper
public interface IUserDao {

    @Delete("delete from user where id = #{id}")
    int delete(long id);

    @Select("select id, name as name, age as age from user")
    List<User> findUserList();

    @Select("select id, name as name, age as age from user where id = #{id}")
    User findUserById(long id);

    @Insert("insert into user(name, age) values(#{user.name}, #{user.age})")
    int add(@Param("user") User user);

    @Update("update user set name = #{user.name}, age = #{user.age} where id = #{user.id}")
    int update(@Param("user") User user);
}
